package com.yanqu.road.server.cmd.tradewar;

import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.cross.tradewar.CrossTradeWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_TRADE_WAR_TO_SERVER_QUERY_CAN_WANTED_RESP, desc = "跨服商战到游戏服查询能否通缉响应")
public class CrossTradeWarToServerQueryCanWantedRespCmd extends CrossUnionCommand {
    private int activityId;
    private long queryUserId;
    private long queryServerId;
    private boolean canWanted;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossTradeWarProto.CrossTradeWarToServerQueryWantedRespMsg reqMsg = CrossTradeWarProto.CrossTradeWarToServerQueryWantedRespMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        queryUserId = reqMsg.getQueryUserId();
        queryServerId = reqMsg.getQueryServerId();
        ret = reqMsg.getRet();
        if(0 == ret) {
            canWanted = reqMsg.getCanWanted();
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossTradeWarProto.CrossTradeWarQueryWantedRespMsg.Builder respMsg = CrossTradeWarProto.CrossTradeWarQueryWantedRespMsg.newBuilder();
        respMsg.setRet(ret);
        if(0 == ret){
            respMsg.setCanWanted(canWanted);
        }
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.U_CROSS_TRADE_WAR_QUERY_CAN_WANTED, respMsg);
        MessageHelper.sendPacket(queryServerId, queryUserId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
